//
//  DSectionIndexItemView.m
//  TableViewIndex
//
//  Created by Dean on 13-4-28.
//  Copyright (c) 2013年 Dean. All rights reserved.
//

#import "DSectionIndexItemView.h"

@interface DSectionIndexItemView ()
@property (nonatomic, strong) UIView *contentView;
@property (nonatomic, strong) UIImageView *backgroundImageView;

@property (nonatomic,retain)  UIView *highlightedView;


@end

@implementation DSectionIndexItemView

- (void)dealloc
{

}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        _contentView = [[UIView alloc] init];
        _contentView.backgroundColor = [UIColor clearColor];
        [self addSubview:self.contentView];
        
        _backgroundImageView = [[UIImageView alloc] init];
        _backgroundImageView.image = nil;
        _backgroundImageView.highlightedImage = [UIImage imageNamed:@"1"];
        _backgroundImageView.layer.cornerRadius = frame.size.height/2;
        _backgroundImageView.clipsToBounds = YES;
        
//        _highlightedView = [[UIView alloc]init];
//        _highlightedView.backgroundColor = [UIColor blueColor];
//        _highlightedView.hidden = YES;
//        [_backgroundImageView addSubview:_highlightedView];
        [self.contentView addSubview:self.backgroundImageView];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = [UIColor blackColor];
        _titleLabel.highlightedTextColor = [UIColor whiteColor];
        _titleLabel.textAlignment = UITextAlignmentCenter;
        [self.contentView addSubview:self.titleLabel];
        
      
        
        
    }
    return self;
}

-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    [_titleLabel setHighlighted:highlighted];
    [_backgroundImageView setHighlighted:highlighted];
    
//    if (highlighted) {
//        _highlightedView.hidden = YES;
//    }else{
//        _highlightedView.hidden = NO;
//    }
    
}

-(void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [self setHighlighted:selected animated:animated];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _contentView.frame = self.bounds;
    _backgroundImageView.frame = self.contentView.bounds;
    _titleLabel.frame = self.contentView.bounds;
    _highlightedView.frame = self.backgroundImageView.bounds;
}


@end
